<!DOCTYPE>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <title>天天放心购－用户中心</title>
    <link rel="stylesheet" th:href="@{/css/reset.css}" type="text/css">
    <link rel="stylesheet" th:href="@{/css/main.css}" type="text/css">
	<script th:src="@{/js/jquery-1.12.4.min.js}" type="text/javascript"></script>
	<script th:src="@{/js/config.js}" type="text/javascript"></script>
</head>
<body>
<!--头部  开始-->
<div th:include="~{global/header :: header}"></div>
<!--头部 结束-->
    <!--内容 开始-->
	<div class="search_bar clearfix">
		<a th:href="@{/index}" class="logo fl"><img th:src="@{/images/logo.png}"></a>
		<div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;用户中心</div>
		<div th:include="~{global/search :: search}"></div>
	</div>
	<div class="main_con clearfix">
		<div class="left_menu_con clearfix">
			<h3>用户中心</h3>
			<ul>
				<li><a th:href="@{/user/record}">· 个人信息</a></li>
				<li><a th:href="@{/user/order/list}">· 全部订单</a></li>
				<li><a th:href="@{/user/address/list}">· 收货地址</a></li>
			</ul>
		</div>
		
		<div class="right_content clearfix">
			<div class="info_con clearfix">
				<h3 class="common_title2">基本信息</h3>
				<ul class="user_info_list">
					<li><span>用户名：</span><em th:text="${session.get('login').uName}"></em></li>
					<li><span>邮　箱：</span><em th:text="${session.get('login').email}"></em></li>
				</ul>
			</div>

			<h3 class="common_title2">推荐商品</h3>
			<div class="has_view_list">
				<ul class="goods_type_list clearfix">
<!--					<c:forEach items="${page.list}" var="record">-->
						<li th:each="record:${pages.list}">
							<a th:href="@{/produce/message(id=${record.productId})}"><img th:src="'/images/所有商品/'+${record.img}"></a>
							<h4><a th:href="@{'/produce/message?id='+${record.productId}}" th:text="${record.shortName}"></a></h4>
							<div class="operate">
								<span class="prize" th:text="'￥'+${record.lookPrice}"></span>
								<span class="unit" th:text="${record.lookPrice}+'/'+${record.lookWeight}+'kg'"></span>
								<a href="javascript:void(0);" th:onclick="|javascript:addCarProduce(${record.productId},1)|" id="add_cart" class="add_goods" title="加入购物车"></a>
							</div>
						</li>
<!--					</c:forEach>-->
				</ul>
			</div>
		</div>
    </div>
	<!--内容 结束-->

<!--底部 开始-->
<div th:include="~{global/header :: footer}"></div>
<!--底部 结束-->
<script>

	let pending=false;
	function addCarProduce(id,count) {
		if (pending) {
			return;
		}
		pending = true;
		$.ajax({
			url: Config.getUrlPreFix() + '/user/car/addProduce',
			contentType: "application/x-www-form-urlencoded",
			method: "POST",
			dataType: "json",
			data: {
				id: id,
				count: count
			},
			success: function (res) {
				if (res.code == 200) {
					alert('添加购物车成功！');
					window.location.href = Config.getUrlPreFix() + '/produce/message?id=' + producePid;
					return;
				}
				alert(res.message);
			},
			// 失败： 提示错误信息
			error: function () {
				alert("请求出错！");
				return
			},
			complete() {
				pending = false;
			}

		})
	};
</script>
</body>
</html>
